package com.ttg.common.enums;

import lombok.Getter;

import java.util.*;

/**
 * @author zhangHongYuan
 * @description
 * @date 2023/8/8 16:42
 */
@Getter
public enum RulesTypeEnum {

    TYPE_1(1, "注册年限","tbl_bank_public_primitive","mct_register_years"),
    TYPE_2(2, "从业年限","tbl_bank_public_primitive","mct_practise_years"),
    TYPE_3(3, "定期存款","tbl_bank_private_primitive_04","amount_last_month_average"),
    TYPE_4(4, "活期存款","tbl_bank_private_primitive_05","amount_last_month_average"),
    TYPE_5(5, "理财金额","tbl_bank_private_primitive_08","amount_last_month_average"),
    TYPE_6(6, "贷款",null,null),
    TYPE_7(7, "有效交易月份数","tbl_bank_public_primitive","mct_transaction_month_number"),
    TYPE_8(8, "收单金额","tbl_bank_public_trade_primitive_101","today_amount"),
    TYPE_9(9, "近三个月收单金额","tbl_bank_public_trade_primitive_101","quarter_amount"),
    TYPE_10(10, "收单笔数","tbl_bank_public_trade_primitive_102","today_amount"),
    TYPE_11(11, "近三个月收单笔数","tbl_bank_public_trade_primitive_102","quarter_amount"),
    TYPE_12(12, "金融资产值","tbl_bank_private_primitive_01","amount_quarter_average");



    private Integer code;

    private String name;

    private String tableName;

    private String columnName;


    RulesTypeEnum(Integer code, String name,String tableName,String columnName) {
        this.code = code;
        this.name = name;
        this.tableName = tableName;
        this.columnName = columnName;
    }
   public static RulesTypeEnum getByCode(Integer code){
        for (RulesTypeEnum value : values()) {
            if (value.getCode().equals(code)){
                return value;
            }
        }
        return null;
    }

    private static final List<Integer> mctCodeGroup = new ArrayList<>();

    private static final List<Integer> vipCodeGroup = new ArrayList<>();

    private static final List<Integer> mctQueryVipGroup = new ArrayList<>();

     static  {
         //对公
         mctCodeGroup.add(RulesTypeEnum.TYPE_1.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_2.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_3.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_4.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_5.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_6.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_7.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_8.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_9.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_10.getCode());
         mctCodeGroup.add(RulesTypeEnum.TYPE_11.getCode());


         //对私
         vipCodeGroup.add(RulesTypeEnum.TYPE_12.getCode());

         //下列对公规则需要查对私资产信息
         mctQueryVipGroup.add(RulesTypeEnum.TYPE_3.getCode());
         mctQueryVipGroup.add(RulesTypeEnum.TYPE_4.getCode());
         mctQueryVipGroup.add(RulesTypeEnum.TYPE_5.getCode());
         mctQueryVipGroup.add(RulesTypeEnum.TYPE_6.getCode());
    }

    public static String mctQueryVipMainTableName (Integer code){
         if (mctQueryVipGroup.contains(code)){
             return "tbl_bank_public_primitive";
         }
         return null;
    }
}
